package com.dao.model;

import java.sql.Timestamp;

/**
 * @author zyf
 */
public class BlockData {

    private char id;
    private String hash;
    private String prehash;
    private int height;
    private int transcount;
    private Timestamp datetime;

    private BlockData(Builder builder) {
        id = builder.id;
        hash = builder.hash;
        prehash = builder.prehash;
        height = builder.height;
        transcount = builder.transcount;
        datetime = builder.datetime;
    }

    public static Builder newBuilder() {
        return new Builder();
    }


    /**
     * {@code BlockData} builder static inner class.
     */
    public static final class Builder {
        private char id;
        private String hash;
        private String prehash;
        private int height;
        private int transcount;
        private Timestamp datetime;

        private Builder() {
        }

        /**
         * Sets the {@code id} and returns a reference to this Builder so that the methods can be chained together.
         *
         * @param id the {@code id} to set
         * @return a reference to this Builder
         */
        public Builder setId(char id) {
            this.id = id;
            return this;
        }

        /**
         * Sets the {@code hash} and returns a reference to this Builder so that the methods can be chained together.
         *
         * @param hash the {@code hash} to set
         * @return a reference to this Builder
         */
        public Builder setHash(String hash) {
            this.hash = hash;
            return this;
        }

        /**
         * Sets the {@code prehash} and returns a reference to this Builder so that the methods can be chained together.
         *
         * @param prehash the {@code prehash} to set
         * @return a reference to this Builder
         */
        public Builder setPrehash(String prehash) {
            this.prehash = prehash;
            return this;
        }

        /**
         * Sets the {@code height} and returns a reference to this Builder so that the methods can be chained together.
         *
         * @param height the {@code height} to set
         * @return a reference to this Builder
         */
        public Builder setHeight(int height) {
            this.height = height;
            return this;
        }

        /**
         * Sets the {@code transcount} and returns a reference to this Builder so that the methods can be chained together.
         *
         * @param transcount the {@code transcount} to set
         * @return a reference to this Builder
         */
        public Builder setTranscount(int transcount) {
            this.transcount = transcount;
            return this;
        }

        /**
         * Sets the {@code datetime} and returns a reference to this Builder so that the methods can be chained together.
         *
         * @param datetime the {@code datetime} to set
         * @return a reference to this Builder
         */
        public Builder setDatetime(Timestamp datetime) {
            this.datetime = datetime;
            return this;
        }

        /**
         * Returns a {@code BlockData} built from the parameters previously set.
         *
         * @return a {@code BlockData} built with parameters of this {@code BlockData.Builder}
         */
        public BlockData build() {
            return new BlockData(this);
        }

        public char getId() {
            return id;
        }

        public String getHash() {
            return hash;
        }

        public String getPrehash() {
            return prehash;
        }

        public int getHeight() {
            return height;
        }

        public int getTranscount() {
            return transcount;
        }

        public Timestamp getDatetime() {
            return datetime;
        }
    }
}
